//
//  BCWalletDetailPagerController.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/12/18.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCWalletDetailPagerController.h"
//
#import "WalletDetailTabBarController.h"
//view
#import "WalletDetailTabBarView.h"

@interface BCWalletDetailPagerController () <WalletDetailTabBarViewDelegate>

@property (nonatomic, strong) WalletDetailTabBarView *tabBarView;

@property (nonatomic, strong) WalletDetailTabBarController *detailTabBarController;

@end

@implementation BCWalletDetailPagerController

- (WalletDetailTabBarView *)tabBarView {
    if (!_tabBarView) {
        _tabBarView = [WalletDetailTabBarView new];
        _tabBarView.delegate = self;
    }
    return _tabBarView;
}

- (WalletDetailTabBarController *)detailTabBarController {
    if (!_detailTabBarController) {
        _detailTabBarController = [WalletDetailTabBarController new];
    }
    return _detailTabBarController;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    //
    self.title = self.title;
    //
    [self setupSubviews];
    //
    [self layoutData];
}
- (void)setupSubviews {
    CGFloat tabBarHeight = [WalletDetailTabBarView defaultHeight];
    [self.view addSubview:self.tabBarView];
    [self.tabBarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.customNaviBar.mas_bottom);
        make.left.mas_equalTo(self.view);
        make.width.mas_equalTo(self.view);
        make.height.mas_equalTo(tabBarHeight);
    }];
    //
    [self.view addSubview:self.detailTabBarController.view];
    [self.detailTabBarController.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.tabBarView.mas_bottom);
        make.left.bottom.right.mas_equalTo(self.view);
    }];
    [self.view layoutIfNeeded];
}
- (void)layoutData {
    self.tabBarView.menus = self.menus;
    self.detailTabBarController.menus = self.menus;
}


#pragma mark - WalletDetailTabBarViewDelegate
- (void)walletDetailTabBarView:(WalletDetailTabBarView *)tabBarView valueChanged:(BCUserWalletDataMenu *)menuItem atIndex:(NSInteger)index {
    self.detailTabBarController.selectedIndex = index;
}

@end
